home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Produtividade / OpenOffice.org 2.0.1 / openofficeorg2.cab / table_of_content.xsl < prev    next >
Extensible Markup Language  |  2005-09-10  |  33KB  |  623 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.     OpenOffice.org - a multi-platform office productivity suite
  5.  
  6.     $RCSfile: table_of_content.xsl,v $
  7.  
  8.     $Revision: 1.6 $
  9.  
  10.     last change: $Author: rt $ $Date: 2005/09/08 22:01:28 $
  11.  
  12.     The Contents of this file are made available subject to
  13.     the terms of GNU Lesser General Public License Version 2.1.
  14.  
  15.  
  16.       GNU Lesser General Public License Version 2.1
  17.       =============================================
  18.       Copyright 2005 by Sun Microsystems, Inc.
  19.       901 San Antonio Road, Palo Alto, CA 94303, USA
  20.  
  21.       This library is free software; you can redistribute it and/or
  22.       modify it under the terms of the GNU Lesser General Public
  23.       License version 2.1, as published by the Free Software Foundation.
  24.  
  25.       This library is distributed in the hope that it will be useful,
  26.       but WITHOUT ANY WARRANTY; without even the implied warranty of
  27.       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  28.       Lesser General Public License for more details.
  29.  
  30.       You should have received a copy of the GNU Lesser General Public
  31.       License along with this library; if not, write to the Free Software
  32.       Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  33.       MA  02111-1307  USA
  34.  
  35. -->
  36. <!--
  37.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  38. -->
  39. <xsl:stylesheet version="1.0"
  40.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  41.     xmlns:office="http://openoffice.org/2000/office"
  42.     xmlns:style="http://openoffice.org/2000/style"
  43.     xmlns:text="http://openoffice.org/2000/text"
  44.     xmlns:table="http://openoffice.org/2000/table"
  45.     xmlns:draw="http://openoffice.org/2000/drawing"
  46.     xmlns:fo="http://www.w3.org/1999/XSL/Format"
  47.     xmlns:xlink="http://www.w3.org/1999/xlink"
  48.     xmlns:number="http://openoffice.org/2000/datastyle"
  49.     xmlns:svg="http://www.w3.org/2000/svg"
  50.     xmlns:chart="http://openoffice.org/2000/chart"
  51.     xmlns:dr3d="http://openoffice.org/2000/dr3d"
  52.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  53.     xmlns:form="http://openoffice.org/2000/form"
  54.     xmlns:script="http://openoffice.org/2000/script"
  55.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  56.     xmlns:meta="http://openoffice.org/2000/meta"
  57.     xmlns:config="http://openoffice.org/2001/config"
  58.     xmlns:help="http://openoffice.org/2000/help"
  59.     xmlns:java="http://xml.apache.org/xslt/java"
  60.     xmlns:sxg="http://www.jclark.com/xt/java/org.openoffice.xslt.OOoMasterDocument"
  61.     xmlns:common="http://exslt.org/common"
  62.     xmlns:xt="http://www.jclark.com/xt"
  63.     xmlns:xalan="http://xml.apache.org/xalan"
  64.     exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help java sxg xt common xalan">
  65.  
  66.     <!-- ****************************** -->
  67.     <!-- ***    Table of Content    *** -->
  68.     <!-- ****************************** -->
  69.  
  70.  
  71.     <xsl:template match="text:table-of-content">
  72.         <xsl:param name="globalData" />
  73.  
  74.         <xsl:apply-templates>
  75.             <xsl:with-param name="globalData" select="$globalData" />
  76.         </xsl:apply-templates>
  77.     </xsl:template>
  78.  
  79.  
  80.     <xsl:template match="text:index-body">
  81.         <xsl:param name="globalData" />
  82.  
  83.         <xsl:choose>
  84.             <xsl:when test="$javaEnabled">
  85.                 <xsl:apply-templates mode="content-table">
  86.                     <xsl:with-param name="globalData" select="$globalData" />
  87.                 </xsl:apply-templates>
  88.             </xsl:when>
  89.             <xsl:otherwise>
  90.                 <xsl:apply-templates>
  91.                     <xsl:with-param name="globalData" select="$globalData" />
  92.                 </xsl:apply-templates>
  93.             </xsl:otherwise>
  94.         </xsl:choose>
  95.     </xsl:template>
  96.  
  97.  
  98.     <xsl:template match="text:index-title" mode="content-table">
  99.         <xsl:param name="globalData" />
  100.  
  101.         <xsl:apply-templates>
  102.             <xsl:with-param name="globalData" select="$globalData" />
  103.         </xsl:apply-templates>
  104.     </xsl:template>
  105.  
  106.  
  107.     <!-- ************************************************ -->
  108.     <!-- *** Create Table for Content Table Paragraph *** -->
  109.     <!-- ************************************************ -->
  110.  
  111.     <!-- Usually the paragraph in a content-table are ordered by tab-stops, which can not be displayed correctly by XHTML/CSS
  112.      Therefore they will be simulated by a table -->
  113.     <xsl:template match="text:p" mode="content-table">
  114.         <xsl:param name="globalData" />
  115.         <xsl:variable name="allTabStopStyles-RTF">
  116.             <xsl:call-template name="get-tab-stops">
  117.                 <xsl:with-param name="globalData" select="$globalData" />
  118.                 <xsl:with-param name="styleName" select="current()/@text:style-name" />
  119.             </xsl:call-template>
  120.         </xsl:variable>
  121.  
  122.         <xsl:element namespace="{$namespace}" name="table">
  123.             <xsl:attribute name="border">0</xsl:attribute>
  124.             <xsl:attribute name="cellspacing">0</xsl:attribute>
  125.             <xsl:attribute name="cellpadding">0</xsl:attribute>
  126.             <xsl:variable name="value" select="$globalData/all-ooo-styles/style[@style:name = current()/@table:style-name]/style:properties/@style:rel-width" />
  127.             <xsl:if test="$value">
  128.                 <xsl:attribute name="width">
  129.                     <xsl:value-of select="$value" />
  130.                 </xsl:attribute>
  131.             </xsl:if>
  132.             <xsl:attribute name="class">
  133.                 <xsl:value-of select="translate(@text:style-name, '. %()/\+', '')" />
  134.             </xsl:attribute>
  135.  
  136.             <xsl:element namespace="{$namespace}" name="colgroup">
  137.                 <xsl:choose>
  138.                     <xsl:when test="function-available('xt:node-set')">
  139.                         <xsl:call-template name="create-col-element">
  140.                             <xsl:with-param name="lastNodePosition" select="count(xt:node-set($allTabStopStyles-RTF)/style:tab-stops/style:tab-stop)" />
  141.                             <xsl:with-param name="allTabStopStyles" select="xt:node-set($allTabStopStyles-RTF)" />
  142.                         </xsl:call-template>
  143.                     </xsl:when>
  144.                     <xsl:when test="function-available('xalan:nodeset')">
  145.                         <xsl:call-template name="create-col-element">
  146.                             <xsl:with-param name="lastNodePosition" select="count(xalan:nodeset($allTabStopStyles-RTF)/style:tab-stops/style:tab-stop)" />
  147.                             <xsl:with-param name="allTabStopStyles" select="xalan:nodeset($allTabStopStyles-RTF)" />
  148.                         </xsl:call-template>
  149.                     </xsl:when>
  150.                     <xsl:when test="function-available('common:node-set')">
  151.                         <xsl:call-template name="create-col-element">
  152.                             <xsl:with-param name="lastNodePosition" select="count(common:node-set($allTabStopStyles-RTF)/style:tab-stops/style:tab-stop)" />
  153.                             <xsl:with-param name="allTabStopStyles" select="common:node-set($allTabStopStyles-RTF)" />
  154.                         </xsl:call-template>
  155.                     </xsl:when>
  156.                     <xsl:otherwise>
  157.                         <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
  158.                     </xsl:otherwise>
  159.                 </xsl:choose>
  160.             </xsl:element>
  161.  
  162.             <!-- all elements before the first tabStop -->
  163.             <xsl:variable name="testNo-RTF">
  164.                 <xsl:apply-templates select="node()" mode="cell-content" />
  165.             </xsl:variable>
  166.  
  167.             <xsl:choose>
  168.                 <xsl:when test="function-available('xt:node-set')">
  169.                     <xsl:variable name="tabNodePositions" select="xt:node-set($testNo-RTF)" />
  170.                     <xsl:element namespace="{$namespace}" name="tr">
  171.                         <xsl:call-template name="create-td-elements">
  172.                             <xsl:with-param name="lastNodePosition" select="count(xt:node-set($allTabStopStyles-RTF)/style:tab-stops/style:tab-stop)" />
  173.                             <xsl:with-param name="position" select="1" />
  174.                             <xsl:with-param name="allTabStopStyles" select="xt:node-set($allTabStopStyles-RTF)" />
  175.                             <xsl:with-param name="tabNodePositions" select="$tabNodePositions" />
  176.                             <xsl:with-param name="globalData" select="$globalData" />
  177.                         </xsl:call-template>
  178.                     </xsl:element>
  179.                 </xsl:when>
  180.                 <xsl:when test="function-available('xalan:nodeset')">
  181.                     <xsl:variable name="tabNodePositions" select="xalan:nodeset($testNo-RTF)" />
  182.                     <xsl:element namespace="{$namespace}" name="tr">
  183.                         <xsl:call-template name="create-td-elements">
  184.                             <xsl:with-param name="lastNodePosition" select="count(xalan:nodeset($allTabStopStyles-RTF)/style:tab-stops/style:tab-stop)" />
  185.                             <xsl:with-param name="position" select="1" />
  186.                             <xsl:with-param name="allTabStopStyles" select="xalan:nodeset($allTabStopStyles-RTF)" />
  187.                             <xsl:with-param name="tabNodePositions" select="$tabNodePositions" />
  188.                             <xsl:with-param name="globalData" select="$globalData" />
  189.                         </xsl:call-template>
  190.                     </xsl:element>
  191.                 </xsl:when>
  192.                 <xsl:when test="function-available('common:node-set')">
  193.                     <xsl:variable name="tabNodePositions" select="common:node-set($testNo-RTF)" />
  194.                     <xsl:element namespace="{$namespace}" name="tr">
  195.                         <xsl:call-template name="create-td-elements">
  196.                             <xsl:with-param name="lastNodePosition" select="count(common:node-set($allTabStopStyles-RTF)/style:tab-stops/style:tab-stop)" />
  197.                             <xsl:with-param name="position" select="1" />
  198.                             <xsl:with-param name="allTabStopStyles" select="common:node-set($allTabStopStyles-RTF)" />
  199.                             <xsl:with-param name="tabNodePositions" select="$tabNodePositions" />
  200.                             <xsl:with-param name="globalData" select="$globalData" />
  201.                         </xsl:call-template>
  202.                     </xsl:element>
  203.                 </xsl:when>
  204.                 <xsl:otherwise>
  205.                     <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
  206.                 </xsl:otherwise>
  207.             </xsl:choose>
  208.         </xsl:element>
  209.     </xsl:template>
  210.  
  211.     <!-- Gathering all tab-stops from a style-hierarchy -->
  212.     <xsl:template name="get-tab-stops">
  213.         <xsl:param name="globalData" />
  214.         <xsl:param name="styleName" />
  215.         <xsl:variable name="tabStyle" select="/*/office:automatic-styles/style:style[@style:name = $styleName]" />
  216.  
  217.         <xsl:if test="$tabStyle/style:properties/style:tab-stops">
  218.             <xsl:copy-of select="$tabStyle/style:properties/style:tab-stops" />
  219.         </xsl:if>
  220.  
  221.         <xsl:if test="$tabStyle/@style:parent-style-name">
  222.             <xsl:call-template name="get-tab-stops">
  223.                 <xsl:with-param name="globalData" select="$globalData" />
  224.                 <xsl:with-param name="styleName" select="$tabStyle/@style:parent-style-name" />
  225.             </xsl:call-template>
  226.         </xsl:if>
  227.     </xsl:template>
  228.  
  229.     <xsl:template name="create-col-element">
  230.         <xsl:param name="lastNodePosition" />
  231.         <xsl:param name="allTabStopStyles" />
  232.  
  233.         <xsl:for-each select="$allTabStopStyles/style:tab-stops/style:tab-stop">
  234.             <xsl:element namespace="{$namespace}" name="col">
  235.                 <xsl:attribute name="style">
  236.                     <xsl:text>width: </xsl:text>
  237.                     <xsl:choose>
  238.                         <xsl:when test="contains(@style:position, 'cm')">
  239.                             <xsl:call-template name="create-cell-width">
  240.                                 <xsl:with-param name="width" select="number(substring-before(@style:position,'cm'))" />
  241.                                 <xsl:with-param name="unit" select="'cm'" />
  242.                                 <xsl:with-param name="position" select="position() - 1" />
  243.                                 <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles" />
  244.                             </xsl:call-template>
  245.                         </xsl:when>
  246.                         <xsl:when test="contains(@style:position, 'in')">
  247.                             <xsl:call-template name="create-cell-width">
  248.                                 <xsl:with-param name="width" select="number(substring-before(@style:position,'in'))" />
  249.                                 <xsl:with-param name="unit" select="'in'" />
  250.                                 <xsl:with-param name="position" select="position() - 1" />
  251.                                 <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles" />
  252.                             </xsl:call-template>
  253.                         </xsl:when>
  254.                         <xsl:when test="contains(@style:position, 'ch')">
  255.                             <xsl:call-template name="create-cell-width">
  256.                                 <xsl:with-param name="width" select="number(substring-before(@style:position,'ch'))" />
  257.                                 <xsl:with-param name="unit" select="'ch'" />
  258.                                 <xsl:with-param name="position" select="position() - 1" />
  259.                                 <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles" />
  260.                             </xsl:call-template>
  261.                         </xsl:when>
  262.                         <xsl:when test="contains(@style:position, 'pt')">
  263.                             <xsl:call-template name="create-cell-width">
  264.                                 <xsl:with-param name="width" select="number(substring-before(@style:position,'pt'))" />
  265.                                 <xsl:with-param name="unit" select="'pt'" />
  266.                                 <xsl:with-param name="position" select="position() - 1" />
  267.                                 <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles" />
  268.                             </xsl:call-template>
  269.                         </xsl:when>
  270.                     </xsl:choose>
  271.  
  272.                 </xsl:attribute>
  273.             </xsl:element>
  274.         </xsl:for-each>
  275.  
  276.     </xsl:template>
  277. <!--
  278. Scenarios tabstops
  279.  
  280. 1) style:type of style:tab-stop is 'right' and earlier tabStop is not right
  281.  -> Earlier text-nodes and following text-nodes, will be put into an inner table, with two TD first aligned left, with proceding textnodes, the latter aligned right.
  282.  
  283. 2) style:type is 'right' and earlier tabStop is right
  284.  -> following text-nodes, will be put into a right aligned TD
  285.  
  286. 3) style:type is 'non-right' and earlier tabStop 'non-right' as well
  287.  -> put the preceding tab stops into a TD (left aligned is default)
  288.  
  289. 4) first style:type would have no right preceding tabStop
  290.  -> works well with first sceanrios 1 and 3
  291.  
  292. 5) last style:type would be a special case, if it would be left aligned, but this won't happen in our case.. :D
  293.  
  294. Scenarios unmatched:
  295. - text:styleposition 'center' will not be matched in our case (effort for nothing), there will be only 'right' and not 'right'
  296. - If the last tabStop is not from text:stylepostion 'right', the length of the last cell is undefined and a document length must be found.
  297.   Not happens in our master document case. Also the algorithm below would have to be expanded (cp. scenario 5).
  298.  
  299. -->
  300.     <xsl:template name="create-td-elements">
  301.         <xsl:param name="globalData" />
  302.         <xsl:param name="lastNodePosition" />
  303.         <xsl:param name="position" />
  304.         <xsl:param name="allTabStopStyles" />
  305.         <xsl:param name="tabNodePositions" />
  306.  
  307.         <xsl:variable name="currentTabStop" select="$allTabStopStyles/style:tab-stops/style:tab-stop[$position]" />
  308.         <xsl:variable name="earlierTabStop" select="$allTabStopStyles/style:tab-stops/style:tab-stop[$position - 1]" />
  309.  
  310.         <xsl:choose>
  311.             <xsl:when test="not($currentTabStop/@style:position) and not($earlierTabStop/@style:position)">
  312.                 <!-- in case no TAB STOP is being set -->
  313.                 <xsl:element namespace="{$namespace}" name="td">
  314.                     <xsl:apply-templates mode="content-table">
  315.                         <xsl:with-param name="globalData" select="$globalData" />
  316.                 </xsl:apply-templates>
  317.                 </xsl:element>
  318.             </xsl:when>
  319.             <xsl:otherwise>
  320.                 <xsl:choose>
  321.                     <xsl:when test="$currentTabStop/@style:type = 'right'">
  322.                         <xsl:choose>
  323.                             <xsl:when test="$earlierTabStop/@style:type = 'right'">
  324.                                 <!--
  325.                                 2) style:type is 'right' and earlier tabStop is right
  326.                                     -> following text-nodes, will be put into a right aligned TD -->
  327.                                 <xsl:element namespace="{$namespace}" name="td">
  328.                                     <xsl:attribute name="style">
  329.                                         <xsl:text>align: right</xsl:text>
  330.                                     </xsl:attribute>
  331.                                     <xsl:call-template name="grap-cell-content-before-tab-stop">
  332.                                         <xsl:with-param name="globalData" select="$globalData" />
  333.                                         <xsl:with-param name="endingTabStopPosition" select="$position + 1" />
  334.                                         <xsl:with-param name="lastNodePosition" select="$lastNodePosition" />
  335.                                         <xsl:with-param name="tabNodePositions" select="$tabNodePositions" />
  336.                                     </xsl:call-template>
  337.                                 </xsl:element>
  338.                             </xsl:when>
  339.                             <xsl:otherwise>
  340.                                 <xsl:element namespace="{$namespace}" name="td">
  341.                                     <xsl:call-template name="grap-cell-content-before-tab-stop">
  342.                                         <xsl:with-param name="globalData" select="$globalData" />
  343.                                         <xsl:with-param name="endingTabStopPosition" select="$position" />
  344.                                         <xsl:with-param name="lastNodePosition" select="$lastNodePosition" />
  345.                                         <xsl:with-param name="tabNodePositions" select="$tabNodePositions" />
  346.                                     </xsl:call-template>
  347.                                 </xsl:element>
  348.                             </xsl:otherwise>
  349.                         </xsl:choose>
  350.                     </xsl:when>
  351.                     <xsl:otherwise>
  352.                         <xsl:choose>
  353.                             <xsl:when test="$earlierTabStop/@style:type = 'right'">
  354.                             </xsl:when>
  355.                             <xsl:otherwise>
  356.                             <!--
  357.                                3) style:type is 'non-right' and earlier tabStop 'non-right' as well
  358.                                     -> put the preceding tab stops into a TD (left aligned is default) -->
  359.                                 <xsl:element namespace="{$namespace}" name="td">
  360.                                     <xsl:call-template name="grap-cell-content-before-tab-stop">
  361.                                         <xsl:with-param name="globalData" select="$globalData" />
  362.                                         <xsl:with-param name="endingTabStopPosition" select="$position" />
  363.                                         <xsl:with-param name="lastNodePosition" select="$lastNodePosition" />
  364.                                         <xsl:with-param name="tabNodePositions" select="$tabNodePositions" />
  365.                                     </xsl:call-template>
  366.                                 </xsl:element>
  367.                             </xsl:otherwise>
  368.                         </xsl:choose>
  369.                     </xsl:otherwise>
  370.                 </xsl:choose>
  371.  
  372.                 <xsl:if test="$position != $lastNodePosition">
  373.                     <xsl:call-template name="create-td-elements">
  374.                         <xsl:with-param name="globalData" select="$globalData" />
  375.                         <xsl:with-param name="lastNodePosition" select="$lastNodePosition" />
  376.                         <xsl:with-param name="position" select="$position + 1" />
  377.                         <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles" />
  378.                         <xsl:with-param name="tabNodePositions" select="$tabNodePositions" />
  379.                     </xsl:call-template>
  380.                 </xsl:if>
  381.             </xsl:otherwise>
  382.         </xsl:choose>
  383.     </xsl:template>
  384.  
  385.  
  386.     <xsl:template name="grap-cell-content-before-tab-stop">
  387.         <xsl:param name="globalData" />
  388.         <xsl:param name="endingTabStopPosition" />
  389.         <xsl:param name="tabNodePositions" />
  390.         <xsl:param name="lastNodePosition" />
  391.  
  392.         <xsl:choose>
  393.             <xsl:when test="$endingTabStopPosition = 1">
  394.                 <xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]]">
  395.                     <xsl:with-param name="globalData" select="$globalData" />
  396.                 </xsl:apply-templates>
  397.             </xsl:when>
  398.             <xsl:when test="$endingTabStopPosition > $lastNodePosition">
  399.                 <xsl:apply-templates mode="content-table" select="node()[position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
  400.                     <xsl:with-param name="globalData" select="$globalData" />
  401.                 </xsl:apply-templates>
  402.             </xsl:when>
  403.             <xsl:otherwise>
  404.                 <xsl:apply-templates mode="content-table" select="node()[position() < $tabNodePositions/tab-stop-node-position[$endingTabStopPosition]][position() > $tabNodePositions/tab-stop-node-position[$endingTabStopPosition - 1]]">
  405.                     <xsl:with-param name="globalData" select="$globalData" />
  406.                 </xsl:apply-templates>
  407.             </xsl:otherwise>
  408.         </xsl:choose>
  409.     </xsl:template>
  410.  
  411.     <!-- As the span width will be mapped to column width, the preceding span widths have to be substracted -->
  412.     <xsl:template name="create-cell-width">
  413.         <xsl:param name="width" />
  414.         <xsl:param name="unit" />
  415.         <xsl:param name="position" />
  416.         <xsl:param name="allTabStopStyles" />
  417.  
  418.         <xsl:choose>
  419.             <!-- beyond second width -->
  420.             <xsl:when test="$position > 1">
  421.                 <xsl:call-template name="create-cell-width">
  422.                     <xsl:with-param name="width" select="$width - number(substring-before($allTabStopStyles/style:tab-stops/style:tab-stop[$position]/@style:position,$unit))" />
  423.                     <xsl:with-param name="unit" select="$unit" />
  424.                     <xsl:with-param name="position" select="$position - 1" />
  425.                     <xsl:with-param name="allTabStopStyles" select="$allTabStopStyles" />
  426.                 </xsl:call-template>
  427.             </xsl:when>
  428.             <!-- second width -->
  429.             <xsl:when test="$position = 1">
  430.                 <xsl:value-of select="concat($width - number(substring-before($allTabStopStyles/style:tab-stops/style:tab-stop[$position]/@style:position,$unit)), $unit)" />
  431.             </xsl:when>
  432.             <!-- first width -->
  433.             <xsl:otherwise>
  434.                 <xsl:value-of select="concat($width, $unit)" />
  435.             </xsl:otherwise>
  436.         </xsl:choose>
  437.     </xsl:template>
  438.  
  439.  
  440.     <!-- ************************************** -->
  441.     <!--    CREATION OF A CONTENT TABLE LINK    -->
  442.     <!-- ************************************** -->
  443.  
  444.  
  445.      <!-- content table link  -->
  446.     <xsl:template match="text:a" mode="content-table">
  447.         <xsl:param name="globalData" />
  448.  
  449.         <!-- For anchors in content-headers a bug exists (cp. bug id# 102311) and they have to be worked out separately.
  450.             Currently the link used in the content-table of an Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
  451.             is not a valid URL (cp. bug id# 102311). No file destination is specified nor exist any anchor element for these
  452.             links in the Office XML, nor is the chapter no. known in the linked files.
  453.             A workaround for this transformation therefore had to be made. This time-consuming mechanism is disabled by default and
  454.             can be activated by a parameter (i.e. 'parseChildDocuments'). A creation of an anchor is made for each header element.
  455.             All header titles gonna be encoding to be usable in a relative URL. -->
  456.         <xsl:choose>
  457.             <xsl:when test="$javaEnabled and $masterDocumentEnabled">
  458.                 <xsl:call-template name="create-content-table-link">
  459.                     <xsl:with-param name="globalData" select="$globalData" />
  460.                 </xsl:call-template>
  461.             </xsl:when>
  462.             <xsl:otherwise>
  463.                 <xsl:call-template name="create-common-anchor-link">
  464.                     <xsl:with-param name="globalData" select="$globalData" />
  465.                 </xsl:call-template>
  466.             </xsl:otherwise>
  467.         </xsl:choose>
  468.     </xsl:template>
  469.  
  470.  
  471.     <!-- a special behavior of text:a
  472.         (called from the 'text:a' template) -->
  473.  
  474.     <xsl:template name="create-content-table-link">
  475.         <xsl:param name="globalData" />
  476.  
  477.         <xsl:element namespace="{$namespace}" name="a">
  478.             <xsl:attribute name="href">
  479.                 <xsl:choose>
  480.                     <xsl:when test="starts-with(@xlink:href, '#')">
  481.                         <xsl:variable name="correctHeading" select="$globalData/content-table-headings/heading[current()/@xlink:href = @content-table-id]" />
  482.                         <xsl:call-template name="get-relative-child-u-r-l">
  483.                             <xsl:with-param name="toChildFileRef" select="$correctHeading/@out-file-url" />
  484.                         </xsl:call-template>
  485.                         <xsl:text>#</xsl:text>
  486.                         <xsl:value-of select="$correctHeading/@absolute-chapter-level" />
  487.                         <xsl:text>_</xsl:text>
  488.                         <xsl:value-of select="$correctHeading/@encoded-title" />
  489.                     </xsl:when>
  490.                     <xsl:otherwise>
  491.                         <xsl:call-template name="create-common-anchor-link">
  492.                             <xsl:with-param name="globalData" select="$globalData" />
  493.                         </xsl:call-template>
  494.                     </xsl:otherwise>
  495.                 </xsl:choose>
  496.             </xsl:attribute>
  497.  
  498.             <xsl:call-template name="apply-styles-and-content">
  499.                 <xsl:with-param name="globalData" select="$globalData" />
  500.             </xsl:call-template>
  501.         </xsl:element>
  502.     </xsl:template>
  503.  
  504.  
  505.     <xsl:template match="text:s" mode="content-table">
  506.         <xsl:call-template name="write-breakable-whitespace">
  507.             <xsl:with-param name="whitespaces" select="@text:c" />
  508.         </xsl:call-template>
  509.     </xsl:template>
  510.  
  511.  
  512.  
  513.     <!-- ***************************************************************** -->
  514.     <!-- *** Extern of ToC - Creating an Anchor Name for every heading *** -->
  515.     <!-- ***************************************************************** -->
  516.  
  517.     <!-- necessary as anchor for the content table -->
  518.     <xsl:template name="create-content-table-anchor">
  519.         <xsl:param name="globalData" />
  520.  
  521.         <!--
  522.         Currently the link used in the Office XML (e.g. in the content table as '#7.Some%20Example%20Headline%7Outline')
  523.         is not a valid URL (cp. bug id# 102311). No file destination is specified nor exist any anchor element for these
  524.         links in the Office XML.
  525.         Here we are creating an anchor with the space normalized text of this header as potential jump address of the content table -->
  526.         <xsl:choose>
  527.             <xsl:when test="$currentChildContentRef">
  528.                 <!-- NOTE: Have to be removed (here a Java-Helper is necessary)  -->
  529.                 <xsl:variable name="currentFileHeadingNo">
  530.                     <xsl:call-template name="get-next-current-file-heading-no">
  531.                         <xsl:with-param name="file" select="$currentChildContentRef" />
  532.                     </xsl:call-template>
  533.                 </xsl:variable>
  534.  
  535.                 <xsl:variable name="testResult" select="$contentTableHeadings/heading[$currentChildContentRef = @file-url][number($currentFileHeadingNo)]" />
  536.                 <xsl:if test="$debugEnabled">
  537.                     <xsl:message>Matching child document header No. <xsl:value-of select="$currentFileHeadingNo" />
  538.                     </xsl:message>
  539.                     <xsl:message>absolute-chapter-level:         <xsl:value-of select="$testResult/@absolute-chapter-level" />
  540.                     </xsl:message>
  541.                     <xsl:message>encodedTitle:                   <xsl:value-of select="$testResult/@encoded-title" />
  542.                     </xsl:message>
  543.                     <xsl:message>currentChildContentRef: <xsl:value-of select="$currentChildContentRef" />
  544.                     </xsl:message>
  545.                     <xsl:message>*** </xsl:message>
  546.                 </xsl:if>
  547.                 <xsl:element namespace="{$namespace}" name="a">
  548.                     <xsl:attribute name="name">
  549.                         <xsl:value-of select="$testResult/@absolute-chapter-level" />
  550.                         <xsl:text>_</xsl:text>
  551.                         <xsl:value-of select="$testResult/@encoded-title" />
  552.                     </xsl:attribute>
  553.                 </xsl:element>
  554.             </xsl:when>
  555.  
  556.             <xsl:otherwise>
  557.                 <!-- When the chapter is in the master document itself the link has to be relative (e.g. #index) a absolute href does not
  558.                     work with the browser. In case of chapter in the master document, the output URL of the master document was taken. -->
  559.                 <xsl:variable name="currentFileHeadingNo">
  560.                     <xsl:call-template name="get-next-current-file-heading-no">
  561.                         <xsl:with-param name="file" select="$contentTableURL" />
  562.                     </xsl:call-template>
  563.                 </xsl:variable>
  564.                 <xsl:variable name="testResult" select="$globalData/content-table-headings/heading[$contentTableURL = @file-url][number($currentFileHeadingNo)]" />
  565.  
  566.                 <xsl:if test="$debugEnabled">
  567.                     <xsl:message>Matching master document header No. <xsl:value-of select="$currentFileHeadingNo" />
  568.                     </xsl:message>
  569.                     <xsl:message>absolute-chapter-level:  <xsl:value-of select="$testResult/@absolute-chapter-level" />
  570.                     </xsl:message>
  571.                     <xsl:message>encodedTitle:            <xsl:value-of select="$testResult/@encoded-title" />
  572.                     </xsl:message>
  573.                     <xsl:message>contentTableURL:         <xsl:value-of select="$contentTableURL" />
  574.                     </xsl:message>
  575.                     <xsl:message>*** </xsl:message>
  576.                 </xsl:if>
  577.  
  578.                 <xsl:element namespace="{$namespace}" name="a">
  579.                     <xsl:attribute name="name">
  580.                         <xsl:value-of select="$testResult/@absolute-chapter-level" />
  581.                         <xsl:text>_</xsl:text>
  582.                         <xsl:value-of select="$testResult/@encoded-title" />
  583.                     </xsl:attribute>
  584.                 </xsl:element>
  585.  
  586.             </xsl:otherwise>
  587.         </xsl:choose>
  588.     </xsl:template>
  589.  
  590.     <xsl:template name="get-relative-child-u-r-l">
  591.         <xsl:param name="toChildFileRef" />
  592.  
  593.         <xsl:choose>
  594.             <xsl:when test="function-available('sxg:get-relative-child-u-r-l')">
  595.                 <xsl:value-of select="sxg:get-relative-child-u-r-l(string($toChildFileRef))" />
  596.             </xsl:when>
  597.             <xsl:when test="function-available('java:org.openoffice.xslt.OOoMasterDocument.getRelativeChildURL')">
  598.                 <xsl:value-of select="java:org.openoffice.xslt.OOoMasterDocument.getRelativeChildURL(string($toChildFileRef))" />
  599.             </xsl:when>
  600.             <xsl:otherwise>
  601.                 <xsl:message terminate="yes">ERROR: Function not found: java:org.openoffice.xslt.OOoMasterDocument.getRelativeChildURL</xsl:message>
  602.             </xsl:otherwise>
  603.        </xsl:choose>
  604.     </xsl:template>
  605.  
  606.  
  607.     <!-- ******************** -->
  608.     <!-- *** Common Rules *** -->
  609.     <!-- ******************** -->
  610.  
  611.     <!-- deactivating default template -->
  612.     <xsl:template match="*" mode="content-table" />
  613.  
  614.     <xsl:template match="*" mode="cell-content">
  615.         <xsl:if test="name() = 'text:tab-stop' or *[name() = 'text:tab-stop']">
  616.             <xsl:element name="tab-stop-node-position" namespace="">
  617.                 <xsl:value-of select="position()" />
  618.             </xsl:element>
  619.         </xsl:if>
  620.     </xsl:template>
  621.  
  622. </xsl:stylesheet>
  623.